<template>
	<el-dialog v-model="visible" :title="dataForm.titleval" :close-on-click-modal="false" draggable>
		<el-card>
			<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList()">
				<el-form-item>
					<el-input v-model="state.queryForm.projectName" placeholder="项目名称" clearable></el-input>
				</el-form-item>
				<el-form-item>
					<el-button @click="getDataList()">查询</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="btnsure()">确定</el-button>
				</el-form-item>
			</el-form>
			<el-table v-loading="state.dataListLoading" :data="state.dataList" border style="width: 100%" @selection-change="selectionHandle">
				<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
				<el-table-column label="序号" type="index" width="60"></el-table-column>
				<el-table-column prop="projectCode" label="项目编码" header-align="center" align="center"></el-table-column>
				<el-table-column prop="projectName" label="项目名称" header-align="center" align="center"></el-table-column>
				<el-table-column prop="projectPrice" label="价格" header-align="center" align="center"></el-table-column>
			</el-table>
			<el-pagination
				:current-page="state.page"
				:page-sizes="state.pageSizes"
				:page-size="state.limit"
				:total="state.total"
				layout="total, sizes, prev, pager, next, jumper"
				@size-change="sizeChangeHandle"
				@current-change="currentChangeHandle"
			>
			</el-pagination>
		</el-card>
	</el-dialog>
</template>

<script setup lang="ts" name="SysPostIndex">
import { useCrud } from '@/hooks'
import { reactive, ref,getCurrentInstance  } from 'vue'
import { IHooksOptions } from '@/hooks/interface'
const visible = ref(false);
let proxy = getCurrentInstance();
const state: IHooksOptions = reactive({
	dataListUrl: '/sys/project/page',
	deleteUrl: '',
	queryForm: {
		projectName: '',
		orgId:localStorage.getItem('org')
	}
})
const dataForm = reactive({
	titleval: '项目列表'
})
const init = () => {
	visible.value = true
}
const selectionHandle=(obj:any)=>{
	if(proxy){
		proxy.emit('fatherProjectMethod',obj);
	}
}

const btnsure=()=>{
	visible.value = false;
}
const { getDataList, selectionChangeHandle, sizeChangeHandle, currentChangeHandle, deleteBatchHandle } = useCrud(state)

defineExpose({
	init
})
</script>
